﻿using System.Configuration;

namespace Wedn.Net.UI.Route
{
    /// <summary>
    /// 约束配置元素的集合
    /// </summary>
    public class ConstraintCollection : ConfigurationElementCollection {
        public Constraint this[int index] {
            get {
                return base.BaseGet(index) as Constraint;
            }

            set {
                if (base.BaseGet(index) != null) {
                    base.BaseRemoveAt(index);
                }
                this.BaseAdd(index, value);
            }
        }

        protected override ConfigurationElement CreateNewElement() {
            return new Constraint();
        }

        protected override object GetElementKey(ConfigurationElement element) {
            return ((Constraint)element).Name;
        }
    }
}
